home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilsys / from.rdm < prev    next >
Text File  |  1996-05-20  |  2KB  |  75 lines

  1. Short:    Best foreach type command ever
  2. Author:   Thomas.Radtke@rz.uni-osnabrueck.de
  3. Uploader: Thomas.Radtke@rz.uni-osnabrueck.de
  4. Type:     util/cli
  5.  
  6. 'from' is a non-standart, AmigaDOS friendly 'foreach' implementation.
  7. The from command will execute a specified command for every line of a given
  8. input source (file or stdin). 'from' is freeware (C) Thomas Radtke 1996.
  9. C Source code included.
  10.  
  11. Syntax: from <list|-> <command> [args]
  12. '-' is treated as stdin.
  13.  
  14. The following _local_ variables will be generated for each line of list:
  15.  
  16. 0    command name
  17. i    where i=1..n and n is the number of words in the line
  18. row    actual row in the list (Note: first line is 0, not 1)
  19.  
  20. You can access the variables in the usual way, i.e. $row,$0,$1,..
  21.  
  22. Examples:
  23.  
  24. (1) dircmp2 -i -p -c bin: c: | from - delete $1
  25.     Deletes all identical files from directory bin. Hey, don't
  26.     try to automatically remove things, this is only an example, ok ?
  27.     (unless you have a reliable undel program ;)
  28.  
  29. (2) from mass_output move $1 waste:mass.$row
  30.     moves all files from the mass_output list to waste: as
  31.     mass.0, mass.1,... (this could be temporary files from somewhere)
  32.  
  33. (3) from mass_output type $1 >>join_them_together
  34.     mass-join operation of files from the list
  35.  
  36. Although 'from' is superior to 'foreach', it doesn't allow any internal
  37. filtering of the input lines (e.g. wildcards, refer to -x,-X options in
  38. dircmp2). I think this is obsolete here, since filtering can be done through
  39. 'edit' or 'sed' in a better way.
  40.  
  41. Reference:
  42.  
  43. dircmp2
  44. -------
  45. The dircmp2 command can be found on Aminet as dircmp2a2.lha (also on CD11?).
  46. An older UN*X version exist in dircmp2.lha.
  47.  
  48. foreach
  49. -------
  50. There is at least one other foreach type command on Aminet, but is is
  51. buggy and has invalidated my HD.
  52.  
  53. move
  54. ----
  55. The move command can be found in various versions on Aminet
  56. (imo best bet is move110.lha, also on Set1,CD A)
  57.  
  58. sed
  59. ---
  60. Beside the GNU binutils, you will find 'sed' on Aminet as ixemul-free
  61. port.
  62.  
  63. Implementation notes:
  64. ---------------------
  65. (i)    The binary was compiled from from.c with the Aminet version of
  66. gcc 2.7.0 and libnix v1.0 static library.
  67.  
  68. (ii)    I am using 'from' successfully on my A4000/EC30/882/2+4/3.0.
  69. You must have at least the dos library V36 (2.0?) to get this to work.
  70. You will not enjoy the processing speed with a M68k CPU.
  71.  
  72. If you like this program, drop me a letter.
  73.  
  74. Thomas
  75.